﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.ComponentModel;

namespace Intel_Client_GUI
{
	/// <summary>
	/// Key.xaml 的交互逻辑
	/// </summary>
	public partial class Key : UserControl,INotifyPropertyChanged
	{
		public Key()
		{
			this.InitializeComponent();
			//this.AddHandler(VirtualKeyboard.ResetColorEvent,new RoutedEventHandler(EventHandler),true);
		}
		
		private string text;
		public string Text
		{
			get
			{
				return text;
			}
			set
			{
				if(text!=value)
				{
					text=value;
					this.NotifyPropertyChanged("Text");
				}
			}
		}
		
		
		public static readonly RoutedEvent VkPressedEvent = EventManager.RegisterRoutedEvent("VirtualKeyPressed",RoutingStrategy.Bubble,typeof(RoutedEventHandler), typeof(Key));
		
		public int KeyValue {set;get;}
		
		public int KeyOp
		{
			set
			{
				this.Masker.Opacity = value;
			}
		}
		
		
		#region INotifyPropertyChanged
		public event PropertyChangedEventHandler PropertyChanged;

    	private void NotifyPropertyChanged(String info)
    	{
        	if (PropertyChanged != null)
        	{
            	PropertyChanged(this, new PropertyChangedEventArgs(info));
        	}
    	}

    	private void UserControl_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
    	{
    		// 在此处添加事件处理程序实现。
			RoutedEventArgs newEventArgs = new RoutedEventArgs(Key.VkPressedEvent,this);
            RaiseEvent(newEventArgs);
    	}
		#endregion
	}
}